package fr.utbm.to52.android_bibtex.controller;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Spinner;
import fr.utbm.to52.android_bibtex.R;
import fr.utbm.to52.android_bibtex.main.AddEntryActivity;
import fr.utbm.to52.android_bibtex.main.FieldActivity;
import fr.utbm.to52.android_bibtex.model.entry.Entry;
import fr.utbm.to52.android_bibtex.model.spec.EntryDefinition;

public class AddEntryController implements OnClickListener {

	private final AddEntryActivity activity;

	public AddEntryController(AddEntryActivity activity) {
		this.activity = activity;
	}

	@Override
	public void onClick(View v) {
		int id = v.getId();

		if (id == this.activity.getNextButton().getId()) {
			Spinner spinner = (Spinner) this.activity.findViewById(R.id.spinner);
			EntryDefinition entryDefinition = (EntryDefinition) spinner.getSelectedItem();
			Intent new_intent = new Intent(this.activity, FieldActivity.class);
			//new_intent.putExtra("entry", new Entry(entryDefinition));
			FieldActivity.entry = new Entry(entryDefinition);
			new_intent.putExtra("createMode", true);
			this.activity.startActivity(new_intent);
		}
	}

}
